.data
XORED_TABLE:
.byte 0xd4,0x3b,0x56,0xb7,0x48,0xd2,0x7d,0xd2,0xc2,0xa4,0xd7,0xc1,0xde,0x73,0xb7,0x21
.byte 0x30,0x40,0x03,0x32,0xa5,0x2f,0x2d,0xb8,0x59,0x7d,0xf0,0xa6,0xe8,0x74,0xf8,0xe0
.byte 0xc0,0x2e,0x6d,0x3a,0xdf,0x35,0xc9,0xb9,0x1c,0xc6,0xfa,0x5f,0x86,0x6b,0x9d,0xd6
.byte 0x0d,0x1d,0x4a,0xe7,0x29,0xc7,0xbe,0x9f,0x07,0x1a,0x45,0xde,0x47,0x9c,0x8c,0x75
.byte 0x22,0xd3,0x33,0xca,0x38,0xdc,0xa6,0xca,0x26,0xdf,0x2f,0xd8,0x32,0xd9,0xf5,0xd8
.byte 0x45,0x8a,0x6e,0xae,0xd4,0xe7,0x18,0x1c,0x26,0x71,0x7a,0xe7,0xa0,0x0d,0x46,0xeb
.byte 0x6c,0x70,0x7a,0xfa,0xb0,0x03,0x31,0x2b,0x8f,0xe7,0xbb,0x28,0x7f,0x7d,0x64,0x61
.byte 0xed,0x36,0xd3,0x70,0x7b,0x71,0x78,0x73,0xe7,0x33,0x80,0x62,0x18,0x24,0x32,0x05
.byte 0x0a,0x3e,0x69,0x76,0xe1,0xa3,0x8c,0x86,0x8b,0x5c,0x09,0x1f,0xc6,0x34,0x63,0x73
.byte 0x63,0xe2,0x2c,0xd6,0xa3,0x48,0x67,0x7f,0x7f,0xf0,0x26,0xd3,0xf0,0x5a,0x04,0x2a
.byte 0x35,0xa6,0x11,0x93,0xd0,0x44,0x9d,0x08,0xc1,0x77,0x22,0xd5,0xb6,0x80,0x00,0xd4
.byte 0xb3,0xce,0x20,0xd2,0xb3,0x8a,0x18,0xcc,0xae,0xce,0x52,0xdf,0xf3,0xcb,0x13,0xbb
.byte 0x0c,0xb3,0x9a,0x4b,0x6b,0xc7,0xa7,0x00,0xd8,0x3e,0x0d,0xb3,0x2f,0xa5,0xb4,0x79
.byte 0x47,0x2a,0x79,0x41,0xcf,0x09,0xf2,0x10,0xeb,0x1f,0x2a,0x88,0x5c,0x78,0x45,0x34
.byte 0x03,0x28,0x3e,0xb5,0x07,0xe0,0xe0,0x5c,0x72,0x59,0x4b,0xb4,0x77,0xe3,0xe3,0x50
.byte 0x0c,0x2e,0x3d,0xbe,0x74,0x91,0xe1,0x2b,0x76,0x2b,0x4b,0xbe,0x74,0x95,0x96,0x5b
.byte 0x34

.align 4
.long 0
XORED_BUFFER:
.skip 128,0

.text
.global __UnXOrSfree
__UnXOrSfree:
    lea     XORED_BUFFER,%eax
    cmp     %eax,4(%esp)
    je      __UnXOrFree_free_local
    push    4(%esp)
    push    $0
    call    _GetProcessHeap@0
    push    %eax
    call    _HeapFree@12
    ret
__UnXOrFree_free_local:
    decl    -4(%eax)
    ret

.global __UnXOrS
__UnXOrS:
    lea     XORED_BUFFER,%eax
    cmpl    $0,-4(%eax)
    jne     __UnXOr_heap_allocate
    cmpl    $128,8(%esp)
    jg      __UnXOr_heap_allocate
    incl    -4(%eax)
    jmp     __UnXOr_buffer
__UnXOr_heap_allocate:
    push    8(%esp)
    push    $0
    call    _GetProcessHeap@0
    push    %eax
    call    _HeapAlloc@12
__UnXOr_buffer:
    push    %esi
    push    %edi
    push    %ecx

    mov     %eax,%edi
    movl    16(%esp),%esi
    movl    $9470854,%eax
    xor     %eax,%esi
    sub     %eax,%esi
    and     $(0x0ffff),%esi
    lea     XORED_TABLE(%esi),%esi
    movl    20(%esp),%ecx
    movl    (%esi),%eax
    incl    %esi
    push    %edi

__UnXOr_loop:
    movb    (%esi),%ah
    xorb    %al,%ah
    movb    %ah,(%edi)
    incl    %esi
    ror     $1,%al
    incl    %edi
    decl    %ecx
    jne     __UnXOr_loop

    pop     %eax
    pop     %ecx
    pop     %edi
    pop     %esi
    ret

